package LeetCode.interview;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import LeetCode.interview._104_Maximum_Depth_of_Binary_Tree.TreeNode;
import sun.tools.jar.resources.jar;
import util.LogUtils;

/*
 * 
原题　
		Given two strings s and t, write a function to determine if t is an anagram of s.
	
	For example,
	s = "anagram", t = "nagaram", return true.
	s = "rat", t = "car", return false.
	
	Note:
	You may assume the string contains only lowercase alphabets.
题目大意
	回文。。
解题思路
	
 * @Date 2017-09-14 23：43
 */
public class _242_Valid_Anagram {
	
	/**
	 * 法一：排序
	 * @My:
	 * @param nums
	 * @return
	 */
    public boolean isAnagram(String s, String t) {
    	if (s==null || t==null)			return false;
    	if (s.length() != t.length())	return false;
    	char[] sArr = s.toCharArray();
    	char[] tArr = t.toCharArray();
    	Arrays.sort(sArr);
    	Arrays.sort(tArr);
    	for (int i = 0; i < s.length(); i ++) {
    		if (sArr[i] != tArr[i])	
    			return false;
    	}
        return true;
    }
	public void traverse(int[] nums) {
		for (int i : nums) {
			LogUtils.print(i);
		}
	}
    
	public static void main(String[] args) {
		_242_Valid_Anagram obj = new _242_Valid_Anagram();
		obj.isAnagram("", "");
	}

}
